/**
 * 
 */
package com.jonosoft.photocast.viewer.web.client;

import java.util.Collection;
import java.util.HashSet;

import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * TODO Add description UserSettings
 * (com.jonosoft.photocast.viewer.web.client.UserSettings)
 * 
 * @author jon
 * 
 */
public class UserSettings implements IsSerializable {

	private static transient String COOKIES_KEY_LOCAL_LIBRARY_LOCATION = "library";
	private static transient String COOKIES_KEY_PHOTOCAST_URL = "photocastURLs";
	
	private String	localLibraryLocation	= null;
	private HashSet	photocastURLs	     = new HashSet();

	public static UserSettings getUserSettings() {
		UserSettings userSettings = new UserSettings();
		
		setAll(userSettings);

		return userSettings;
	}
	
	private static void setAll(UserSettings userSettings) {
		userSettings.setLocalLibraryLocation();
		userSettings.setPhotocastURLs();
	}

	/**
	 * @return the localLibraryLocation
	 */
	public String getLocalLibraryLocation() {
		return this.localLibraryLocation;
	}

	/**
	 * @return the photocastURLs
	 */
	public HashSet getPhotocastURLs() {
		return this.photocastURLs;
	}

	/**
	 * @param localLibraryLocation
	 *            the localLibraryLocation to set
	 */
	public void setLocalLibraryLocation(String localLibraryLocation) {
		this.localLibraryLocation = localLibraryLocation;
	}

	/**
	 * @param photocastURLs
	 *            the photocastURLs to set
	 */
	public void setPhotocastURLs(HashSet photocastURLs) {
		this.photocastURLs = photocastURLs;
	}
	
	public void addPhotocastURL(String photocastURL) {
		this.photocastURLs.add(photocastURL);
	}
	
	public void addPhotocastURLs(Collection photocastURLs) {
		this.photocastURLs.addAll(photocastURLs);
	}
	
	public void setLocalLibraryLocation() {
		setLocalLibraryLocation(Cookies.getCookie(COOKIES_KEY_LOCAL_LIBRARY_LOCATION));
	}
	
	public void setPhotocastURLs() {
		addPhotocastURL("http://photocast.mac.com/skater0i/iPhoto/landon---all/index.rss");
		addPhotocastURL("http://photocast.mac.com/skater0i/iPhoto/landon-pics-for-web/index.rss");
	}

}
